package jsu.lipengcheng.trafficnet.Ai.Tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import jsu.lipengcheng.trafficnet.mapper.AdminMapper;
import jsu.lipengcheng.trafficnet.pojo.Admins;
import jsu.lipengcheng.trafficnet.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class FindService {
    @Autowired
    private NewsService newsService;

    @Autowired
    private AdminMapper adminMapper;

    @Tool("查询新闻的总体数量")
    public int findnews(){
        return newsService.selectsum();
    }

    @Tool("帮用户注册信息")
    public void insertuser(
           @P("用户名") String username,
           @P("用户密码") String password
    ){
        Admins admins = new Admins(null,username,password);
        adminMapper.insert(admins);
    }
}
